<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">


  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <title>代码框</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<!--begin code mirror -->
<!--下面两个是使用Code Mirror必须引入的-->
<link rel="stylesheet" href="/jslib/codemirror/lib/codemirror.css"/>
<script src="/jslib/codemirror/lib/codemirror.js"></script>
<!--Java代码高亮必须引入-->
<script src="/jslib/codemirror/mode/clike/clike.js"></script>
<!--groovy代码高亮-->
<script src="/jslib/codemirror/mode/groovy/groovy.js"></script>
<!--引入css文件，用以支持主题-->
<link rel="stylesheet" href="/jslib/codemirror/theme/dracula.css"/>

<!--支持代码折叠-->
<link rel="stylesheet" href="/jslib/codemirror/addon/fold/foldgutter.css"/>
<script src="/jslib/codemirror/addon/fold/foldcode.js"></script>
<script src="/jslib/codemirror/addon/fold/foldgutter.js"></script>
<script src="/jslib/codemirror/addon/fold/brace-fold.js"></script>
<script src="/jslib/codemirror/addon/fold/comment-fold.js"></script>
<!--括号匹配-->
<script src="/jslib/codemirror/addon/edit/matchbrackets.js"></script>
<!--end Code Mirror -->

  </head>
  <body>
    <h1>Hello, world!</h1>
    <button type="button" class="btn btn-primary btn-lg" id="btn1">提交</button>
    <p>如果您点击我，我会消失。</p>
	<p>点击我，我会消失。</p>
	<p>也要点击我哦。</p>
    <hr>
    <div>
		<form action="/codemirror/code1do.html" method="POST">
	    <!-- begin code -->
	    <div class="form-group">
		    <label for="code">CodeMirror代码编写</label>
		    <textarea class="form-control" id="code" name="code"></textarea>
		 </div>
	    <!-- end code-->
	    </form>
	</div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
    
    <script>
    //根据DOM元素的id构造出一个编辑器
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
        mode: "text/groovy",    //实现groovy代码高亮
        mode: "text/x-java", //实现Java代码高亮
        lineNumbers: true,	//显示行号
        theme: "dracula",	//设置主题
        lineWrapping: true,	//代码折叠
        foldGutter: true,
        gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
        matchBrackets: true,	//括号匹配
        //readOnly: true,        //只读
    });
    editor.setSize('800px', '950px');     //设置代码框的长宽

    editor.setValue("");    //先代码框的值清空
    //editor.setValue(obj.scriptCode);    //给代码框赋值

    // editor.setOption("readOnly", true);
    
/*     $("btn1").click(function(){
	  alert("111");
	}); */
    
    $(document).ready(function(){
        $("#btn1").click(function(){
        	$("form").submit();
      	});
        $("p").click(function(){
            $(this).hide();
        });
    });

	</script>
	
  </body>
  
</html>